package com.cloudm.technician.ui.base

import android.annotation.SuppressLint
import android.app.Dialog
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.View
import com.cloudm.technician.R
import kotlinx.android.synthetic.main.common_loading_view.view.*

/**
 * 作者: wesley
 * 时间: 2017/11/22
 * 描述:
 */
class LoadingDialogFragment : BaseDialogFragment() {

    private var value: String? = null

    override fun handleBundle(bundle: Bundle) {
        value = bundle.getString(LOADING_VALUE_KEY)
    }

    @SuppressLint("InflateParams") override fun createDialog(): Dialog {
        val view: View = LayoutInflater.from(mContext).inflate(R.layout.common_loading_view, null)
        view.loadingValue.text = value
        return AlertDialog.Builder(mContext).setView(view).create()
    }

    companion object {
        private const val LOADING_VALUE_KEY = "loading_value_key"
        fun newInstance(value: String) = LoadingDialogFragment().apply {
            arguments = Bundle().apply {
                putString(LOADING_VALUE_KEY, value)
            }
        }
    }

}